'''
数据库连接删除
'''
from pymysql import Connection

conn = None
cursos = None
try:
    conn = Connection(
        user="root",
        password="123456",
        database="mydb1",
        port=3306,
        charset="utf8"
    )
    cursor = conn.cursor()
    sql = '''
        DELETE FROM hero WHERE id = 4;
    '''
    cursor.execute(sql)
    conn.commit()
except Exception as e:
    print(e)
finally:
    if cursos:
        cursos.close()
    if conn:
        conn.close()